<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<!DOCTYPE html>
<html lang="en">
  <head>
     <%@include file="/WEB-INF/jsp/common/style.jsp"%>
  </head>
  <body>
    <div id="wrap">
    
	<form class="form-horizontal"  id="seachform" action="${pageContext.request.contextPath}/set/role/index"	method="post">
    <div   class="container-fluid">
     
      <!-- Main window -->
      <div class="main_container" id="dashboard_page">

		 <div class="row-fluid">
          <div class="widget widget-padding span12">
          <h4 class="widget-head-title">角色管理</h4>
									<div class="widget-header">
										<span>首页&nbsp;>&nbsp;角色管理</span>
			</div>
		  <div class="row-fluid" style="background-color:#fff;padding:20px 20px;">
               <div class="table-scroll">
                   <table  style="line-height: 40px; text-align: left;padding:20px 20px" >
                       <tr>
                           <td width="70px">角色编号:</td>
                           <td><input name="roleId" value="${model.roleId}"  type="text" class=""/></td>
                           <td width="70px">角色名称:</td>
                           <td ><input name="roleName" value="${model.roleName}" type="text" class="" /></td>
                           <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                       </tr>

                   </table>
               </div>
        </div>
       </div>
      </div>
      
       <div class="row-fluid">
      	 <div>
               <input class="btn btn-primary" type="submit" value="查询"/>          
               <input class="btn btn-success buttonrole"   name="btnadd"   type="button" onclick="edit('')" value="新增">
                   
            </div>
		</div>
		<div class="row-fluid">
          <div class="widget widget-padding span12">
            <div class="widget-header">
              <i class="icon-group"></i>
              <h5>查询结果</h5>
            
            </div>  
            <div class="widget-body">
              <div class="table-scroll">
                  <table id="users" class="table table-striped table-bordered dataTable">
                      <thead>
                      <tr>
                          <th>角色编号</th>
                          <th>角色名称</th>
                          <th>创建人</th>
                          <th>创建时间</th>
                          <th>修改人</th>
                          <th>修改时间</th>
                          <th>操作</th>
                      </tr>
                      </thead>
                      <tbody>
                      <tr>
                          <c:forEach items="${model.items}" var="item" varStatus="itemStatus">
                      <tr  id="row_${item.id}">
                          <td>${item.id}</td>
                          <td>${item.roleName}</td>
                          <td>${item.createUserName}</td>
                          <td><fmt:formatDate value="${item.createTime}"  type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                          <td>${item.updateUserName}</td>
                          <td><fmt:formatDate value="${item.updateTime}"  type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td>

                          <td align="center" align="center" >
                              <c:if test='${item.id!=-1}'>
                                  <a  href="javascript:edit('${item.id}');" name="btnedit"  class="buttonrole" style="margin-left: 5px;"  >编辑</a>
                                  <a  href="javascript:configMenu('${item.id}');" name="btnrole" class="buttonrole" style="margin-left: 5px;" >权限设置</a>
                                  <a  href="javascript:delRole('${item.id}',1);" name="btndel"  class="buttonrole" style="margin-left: 5px;"  >删除</a>
                              </c:if>




                          </td>
                      </tr>
                      </c:forEach>
                      </tr>

                      </tbody>
                  </table>

              </div></div> <!-- /widget-body -->
       		<div class="pagin" class="widget-footer">
             	<vp:pages  cpage="${model.cpage}"  totalCount="${model.totalCount}"  pageSize="${model.pageSize}"   />
   			</div>   
          </div> <!-- /widget -->
        </div> <!-- /row-fluid -->
        
      <!-- /Main window -->
      
    	</div>
    </div>
    </form>
    </div><!-- wrap ends-->
	
  	<div id="edit" style="display:none;width: 100%;height: 100%;overflow:hidden;position:absolute;left:0;top:0;right:0;bottom:0;">
        <iframe id="editFrame" width="100%" height="100%"  frameborder="0" border="0" scrolling="auto"></iframe>
    </div>
   
  </body>
  <script type="text/javascript">
	function seach(){
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
	    $("#btnOk").attr("disabled", "disabled");	  
	    var objform = document.getElementById('seachform');
	    objform.submit();
	}	
	function delRole(id){		
		layer.confirm('确认要删除此角色吗', {
			  btn: ['确认','取消'] //按钮
			}, function(){
				sendOpTo(id);
			}, function(){
			  
			});			
	}
	function sendOpTo(id){
		layer.load(1, {shade: [0.5,'#fff']});
		var postData="roleId=" + id;
		 $.ajax({
	            type: "POST",
	            url: "delRole",
	            data: postData,
	            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	            async: true, // 同步  true 异步。默认是异步
	            dataType: 'json',
	            error: function(resultdata) {
	            	layer.closeAll();
	            },
	            success: function(resultdata) {
	            	layer.closeAll();
	                if(resultdata.returnCode=="0000"){               	
	                	layer.alert('操作成功',{icon: 1}, function(){
	                		layer.closeAll();
	                	 	 oksubmit();
	                	});
	                }else{
	                	layer.alert(resultdata.returnMessage);
	                }
	            }
	        });
	}
	
    function editReturn() {
       layer.closeAll();
       oksubmit();
    }
    function closeAll() {
        layer.closeAll();
     }
    function edit(id){
		var domainUrl="edit?roleId=" + id;
		layer.open({
			  type: 2,
			  title: '角色',
			   area: ['550px', '430px'],
			   content: domainUrl //iframe的url
	      }); 
		// $('#wrap').hide();
	    // $('#editFrame').attr("src", domainUrl);
	     //$('#edit').show(); 
	}
    function configMenu(id){
    	var domainUrl="config?roleId=" + id;
		
		 $('#wrap').hide();
	     $('#editFrame').attr("src", domainUrl);
	     $('#edit').show(); 
    }
	function reset(userId){
		var postData="userId=" + userId;
		 $.ajax({
	            type: "POST",
	            url: "resetPassword",
	            data: postData,
	            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	            async: true, // 同步  true 异步。默认是异步
	            dataType: 'json',
	            error: function(resultdata) {
	            	layer.closeAll();
	            },
	            success: function(resultdata) {
	            	layer.closeAll();
	                if(resultdata.returnCode=="0000"){               	
	                	layer.alert('操作成功',{icon: 1}, function(){
	                		layer.closeAll();
	                	 	 oksubmit();
	                	});
	                }else{
	                	layer.alert(resultdata.returnMessage);
	                }
	            }
	        });
	}
	</script>
</html>
